import 'package:tiktokadult/hj_page/live/live_model.dart';
import 'package:tiktokadult/tools_base/net/net_manager.dart';
import 'package:tiktokadult/hj_utils/http_manager.dart';

class LiveService {
  //获取直播模块
  static Future<LiveMainModel?> getLiveModuleList() async {
    int time = netManager.getFixedCurTime().toUtc().millisecondsSinceEpoch ~/ 1000;
    final param = {'time': time};
    final result = await httpManager.fetchResponseByPOST(
      '/live/module/list/hjll',
      param: param,
      jsonTransformation: (json) => LiveMainModel.fromJson(json),
    );
    return result.data;
  }

  //获取直播模块
  static Future<LiveAnchors?> getLiveAnchorList({
    String? id,
    int? pageNumber,
    int? pageSize,
  }) async {
    int time = netManager.getFixedCurTime().toUtc().millisecondsSinceEpoch ~/ 1000;
    final param = {
      'time': time,
      'id': id,
      'pageNumber': pageNumber,
      'pageSize': 20,
    };
    final result = await httpManager.fetchResponseByPOST(
      '/live/anchor/list/hjll',
      param: param,
      jsonTransformation: (json) => LiveAnchors.fromJson(json),
    );
    return result.data;
  }

  //获取直播详情模块
  static Future<LiveAnchor?> getLiveAnchorDetail({String? id}) async {
    int time = netManager.getFixedCurTime().toUtc().millisecondsSinceEpoch ~/ 1000;
    final param = {
      'time': time,
      'id': id,
    };
    final result = await httpManager.fetchResponseByPOST(
      '/live/anchor/watch/hjll',
      param: param,
      jsonTransformation: (json) => LiveAnchor.fromJson(json),
    );
    return result.data;
  }

  //获取直播详情推荐列表
  static Future<LiveAnchors?> getLiveAnchorRecom({
    String? country,
    int? pageNumber,
    int? pageSize,
  }) async {
    int time = netManager.getFixedCurTime().toUtc().millisecondsSinceEpoch ~/ 1000;
    final param = {
      'time': time,
      'country': country,
      'pageNumber': pageNumber,
      'pageSize': pageSize,
    };
    final result = await httpManager.fetchResponseByPOST(
      '/live/anchor/recom/hjll',
      param: param,
      jsonTransformation: (json) => LiveAnchors.fromJson(json),
    );
    return result.data;
  }
}
